package com.victor9ac.tfm.twitter;

import static org.junit.Assert.*;

import java.util.List;

import static junit.framework.Assert.assertNotNull;

import org.junit.Before;
import org.junit.Test;

import com.victor9ac.tfm.provider.api.Commentaries;

import twitter4j.Status;

public class TwitterServiceIt {

	
	public static final String ANY_TWEET_FOR_SEARCH = "La barrosa";
	
	TwitterService twitterService;
	
	
	@Before
	public void setUp(){
		this.twitterService = TwitterService.getInstance();
	}
	
	@Test
	public void obtainTweets() throws Exception {
		
		
		
		List<Status>statusList = twitterService.getTweets(ANY_TWEET_FOR_SEARCH);
		
		assertNotNull("debe devolver una lista de tweets ", statusList);
		
		printTwitterStatusList(statusList);	
	}
	
	
	@Test
	public void obtainCommentaries() throws Exception {
		Commentaries commentaries = twitterService.getCommentariesTweets(ANY_TWEET_FOR_SEARCH);
		
		assertNotNull("no se obtuvieron comentarios", commentaries);
		
		System.out.println(commentaries);
	}

	private void printTwitterStatusList(List<Status> statusList) {
		for (Status status : statusList) {
	        System.out.println(status.getUser().getName() + ":" +
                    status.getText());
	        }
	}
}
